import { request } from 'ice';
var qs = require('querystringify');
export async function post(url: string, body: Object) {
    const data = await request({
        url: (process.env.NODE_ENV === 'development' ? '/api' : '') + url,
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        data: body
    });
    return data;
}
export async function del(url: string, body: Object) {
    const data = await request({
        url: (process.env.NODE_ENV === 'development' ? '/api' : '') + url,
        method: 'delete',
        headers: {
            'Content-Type': 'application/json'
        },
        data: body
    });
    return data;
}
export async function get(url: string, params?: any, options: any = {}) {
    const queryStr = qs.stringify(params);
    const data = await request({
        url: (process.env.NODE_ENV === 'development' ? '/api' : '') + url + (queryStr ? ((url.indexOf('?') > -1 ? '&' : '?') + queryStr) : ''),
        ...options,
        headers: {
            'Content-Type': 'application/json',
            ...options.headers
        },
    });
    return data.content;
}